<?php 
	$db_connect = mysqli_connect("localhost", "root", "", "imperial_traktors");
	
	
	if(isset($_POST['submit']))
	{
		$name = $_POST['name'];
		$model = $_POST['model'];
		$price = $_POST['price'];
		$file =  $_FILES["file"]["name"];
		$img_name = $name.$file;
		move_uploaded_file($_FILES["file"]["tmp_name"],"pictures/" . $img_name);
		//$user_id = $_POST['user_id'];
		$insert = "INSERT INTO `traktor`(`name`, `model`, `img`, `price`, `user_id`) 
				VALUES (\"$name)\", \"$model\", \"$img_name\", $price, 1)";
		
		mysqli_query($db_connect, $insert);
		
		mysqli_close($db_connect);
		header("Location: index.php");
	}
?>
<html>
<head>
	<title>Add traktors</title>
</head>
<body>

<?php

	
		echo "<form method=\"post\" action=\"add_traktors.php\" enctype=\"multipart/form-data\">";
		echo "<p>Name <input name=\"name\"  /></p>\n";
		echo "<p>Model <input name=\"model\" /></p>\n";
		echo "<p>price <input name=\"price\" /></p>\n";
	
	
?>
<p>Image:
<input type="file" name="file" id="file"></p>
<input type="submit" value="submit" name="submit"/>
</form>
</body>
</html>